<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="状态:" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择审核状态" clearable size="mini" @change="getList">
          <el-option v-for="dict in dict.type['interlace_kyc_status']"
                     :key="dict.value"
                     :label="dict.label"
                     :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="性别:" prop="gender">
        <el-select v-model="queryParams.gender" placeholder="请选择审核状态" clearable size="mini" @change="getList">
          <el-option v-for="dict in dict.type['interlace_gender']"
                     :key="dict.value"
                     :label="dict.label"
                     :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="姓名:" prop="firstName">
        <el-input
          size="mini"
          v-model="queryParams.firstName"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号:" prop="phoneNumber">
        <el-input
          size="mini"
          v-model="queryParams.phoneNumber"
          placeholder="请输入手机号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="国籍:" prop="nationalityName">
        <el-input
          size="mini"
          v-model="queryParams.nationalityName"
          placeholder="请输入国籍"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="居住地:" prop="addressCountryName">
        <el-input
          size="mini"
          v-model="queryParams.addressCountryName"
          placeholder="请输入居住地"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="创建时间:">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          format="yyyy-MM-dd"
          value-format="timestamp"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="['00:00:00', '23:59:59']"
          size="mini"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="序号" type="index" align="center" min-width="5%"/>
      <el-table-column label="姓氏" align="center" prop="lastName" key="lastName"/>
      <el-table-column label="名字" align="center" prop="firstName" key="firstName"/>
      <el-table-column label="国籍" align="center" prop="nationalityName" key="nationalityName"/>
      <el-table-column label="手机区号" align="center" prop="phoneCountryCode" key="phoneCountryCode"/>
      <el-table-column label="手机号" align="center" prop="phoneNumber" key="phoneNumber"/>
      <el-table-column label="状态" align="center" prop="status" key="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.interlace_kyc_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleInfo(scope.row)"
            v-hasPermi="['system:kyc:query']"
          >详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <el-dialog title="kyc详情" :visible.sync="detailOpen" width="50%" append-to-body>
      <el-form ref="form" :model="detail" label-width="140px">
        <el-row :gutter="24">
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="姓氏: ">
                {{ detail.lastName }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="名字: ">
                {{ detail.firstName }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="出生日期: ">
                {{ detail.dateOfBirth }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="性别: ">
                <dict-tag :options="dict.type.interlace_gender" :value="detail.gender"/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="国籍: ">
                {{ detail.nationalityName }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="证件类型: ">
                <dict-tag :options="dict.type.interlace_id_type" :value="detail.idType"/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="证件发证日期: ">
                {{ detail.issueDate }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="证件过期日期: ">
                {{ detail.expiryDate }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="国民身份证号码: ">
                {{ detail.nationalId }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="社会安全号码: ">
                {{ detail.ssn }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="证件正面: ">
                <span v-if="detail.idFrontUrl === null || detail.idFrontUrl === ''">暂无</span>
                <div v-else class="viewer-list-img">
                  <viewer :images="detail.idFrontUrl">
                    <image-preview :src="detail.idFrontUrl" :key="detail.idFrontUrl" class="detail-img"/>
                  </viewer>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="证件反面: ">
                <span v-if="detail.idBackUrl === null || detail.idBackUrl === ''">暂无</span>
                <div v-else class="viewer-list-img">
                  <viewer :images="detail.idBackUrl">
                    <image-preview :src="detail.idBackUrl" :key="detail.idBackUrl" class="detail-img"/>
                  </viewer>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="24">
            <div class="grid-content bg-purple">
              <el-form-item label="自拍照: ">
                <span v-if="detail.selfieUrl === null || detail.selfieUrl === ''">暂无</span>
                <div v-else class="viewer-list-img">
                  <viewer :images="detail.selfieUrl">
                    <image-preview :src="detail.selfieUrl" :key="detail.selfieUrl" class="detail-img"/>
                  </viewer>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="手机区号: ">
                {{ detail.phoneCountryCode }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="手机号: ">
                {{ detail.phoneNumber }}
              </el-form-item>
            </div>
          </el-col>

          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="居住地址(国家): ">
                {{ detail.addressCountryName }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="居住地址(州/省): ">
                {{ detail.addressStateName }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="居住地址(城市): ">
                {{ detail.city }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="居住地址(地址1): ">
                {{ detail.addressLine1 }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="居住地址(地址2): ">
                {{ detail.addressLine2 }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="居住地址(邮编): ">
                {{ detail.postalCode }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="创建时间: ">
                {{ parseTime(detail.createTime) }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content bg-purple">
              <el-form-item label="状态: ">
                <dict-tag :options="dict.type.interlace_kyc_status" :value="detail.status"/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="24">
            <div class="grid-content bg-purple">
              <el-form-item label="驳回理由: ">
                {{ detail.failRemark }}
              </el-form-item>
            </div>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="detailOpen = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {pageList, getDetail} from '@/api/triones/interlaceKyc'

export default {
  name: "index",
  dicts: ['interlace_kyc_status', 'interlace_gender', 'interlace_id_type'],
  data() {
    return {
      loading: false,
      showSearch: true,
      // 日期范围
      dateRange: [],
      auditDateRange: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        status: undefined,
        gender: undefined,
        firstName: undefined,
        phoneNumber: undefined,
        nationalityName: undefined,
        addressCountryName: undefined
      },
      dataList: [],
      total: 0,
      detailOpen: false,
      detail: {}
    }
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      this.addDateRange(this.queryParams, this.auditDateRange, 'AuditTime');
      this.addDateRange(this.queryParams, this.dateRange);
      pageList(this.queryParams).then(res => {
        this.dataList = res.rows;
        this.total = res.total;
        this.loading = false;
      })
    },
    /** 检索 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置 */
    resetQuery() {
      this.dateRange = [];
      this.auditDateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 查询详情 */
    handleInfo(row) {
      const id = row.id;
      getDetail(id).then(response => {
        this.detail = response.data;
        this.detailOpen = true;
      })
    },
  }
}
</script>
<style scoped lang="scss">

</style>
